{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import time\n",
    "import scipy\n",
    "import json\n",
    "import Additive_mixing_layers_extraction\n",
    "from scipy.spatial import ConvexHull, Delaunay\n",
    "import scipy.sparse\n",
    "import PIL.Image as Image\n",
    "Image.MAX_IMAGE_PIXELS = 1000000000\n",
    "import RGBXY_method_modified_for_huge_image\n",
    "from numpy import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# ### 100MP images\n",
    "base_dir=\"./Large_images/\"\n",
    "import glob\n",
    "filepaths=glob.glob(base_dir+\"*.jpg\")\n",
    "print filepaths\n",
    "\n",
    "for filepath in filepaths:\n",
    "    print \"#####################\"\n",
    "    print filepath\n",
    "    img=np.asfarray(Image.open(filepath).convert('RGB'))/255.0\n",
    "    X,Y=np.mgrid[0:img.shape[0], 0:img.shape[1]]\n",
    "    XY=np.dstack((X*1.0/img.shape[0],Y*1.0/img.shape[1]))\n",
    "    data=np.dstack((img, XY))\n",
    "    print len(data.reshape((-1,5)))\n",
    "    \n",
    "    start=time.time()\n",
    "    palette_rgb=Additive_mixing_layers_extraction.Hull_Simplification_determined_version(img, filepath[:-4]+\"-convexhull_vertices\")\n",
    "    end=time.time()    \n",
    "    M=len(palette_rgb)\n",
    "    print \"palette size: \", M\n",
    "    print \"palette extraction time: \", end-start\n",
    "\n",
    "\n",
    "    ######### for RGBXY method\n",
    "    start=time.time()\n",
    "    data_hull=ConvexHull(data.reshape((-1,5)))\n",
    "    start2=time.time()\n",
    "    print \"5D convexhull vertices number: \", len(data_hull.vertices)\n",
    "    print \"convexhull on 5D time: \", start2-start\n",
    "    mixing_weights_2=RGBXY_method_modified_for_huge_image.recover_ASAP_weights_using_scipy_delaunay(data_hull.points[data_hull.vertices], data_hull.points)\n",
    "    end=time.time()\n",
    "    print \"total time: \", end-start\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
